package com.woniu.market_stall.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.entity.ManagerDept;
import com.woniu.market_stall.entity.Role;
import com.woniu.market_stall.mapper.ManagerDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    ManagerDeptMapper mapper;

    public  List<ManagerDept> queryAllDept() {
        return mapper.selectAll();
    }

    public int removeByKey(Integer id){
        return mapper.deleteByPrimaryKey(id);
    }

    public void add(ManagerDept managerDept) {
        mapper.insert(managerDept);
    }

    public void modify(ManagerDept managerDept) {
        mapper.updateByPrimaryKey(managerDept);
    }

    public PageInfo<ManagerDept> queryDepartmentByPage(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<ManagerDept> list = mapper.selectDepartmentByName(name);
        return new PageInfo<>(list);
    }
}
